package io.github.libkodi.session;

import java.util.Set;

import io.github.libkodi.session.interfaces.Session;
import io.vertx.core.Future;

public class SessionImpl implements Session {

	private DataCenter data;
	private String sessionId;

	public SessionImpl(String sessionId, DataCenter data) {
		this.data = data;
		this.sessionId = sessionId;
	}

	@Override
	public Future<String> getString(String key) {
		return data.getHashString(sessionId, key);
	}

	@Override
	public Future<Integer> getInteger(String key) {
		return data.getHashInteger(sessionId, key);
	}

	@Override
	public Future<Double> getDouble(String key) {
		return data.getHashDouble(sessionId, key);
	}

	@Override
	public Future<Float> getFloat(String key) {
		return data.getHashFloat(sessionId, key);
	}

	@Override
	public Future<Long> getLong(String key) {
		return data.getHashLong(sessionId, key);
	}

	@Override
	public Future<Boolean> getBoolean(String key) {
		return data.getHashBoolean(sessionId, key);
	}

	@Override
	public <T> Future<T> getJavaObject(String key, Class<T> clazz) {
		return data.getHashJavaObject(sessionId, key, clazz);
	}

	@Override
	public Future<Void> setString(String key, String value) {
		return data.setHashString(sessionId, key, value);
	}

	@Override
	public Future<Void> setInteger(String key, int value) {
		return data.setHashInteger(sessionId, key, value);
	}

	@Override
	public Future<Void> setDouble(String key, double value) {
		return data.setHashDouble(sessionId, key, value);
	}

	@Override
	public Future<Void> setFloat(String key, float value) {
		return data.setHashFloat(sessionId, key, value);
	}

	@Override
	public Future<Void> setLong(String key, long value) {
		return data.setHashLong(sessionId, key, value);
	}

	@Override
	public Future<Void> setBoolean(String key, boolean value) {
		return data.setHashBoolean(sessionId, key, value);
	}

	@Override
	public Future<Void> setJavaObject(String key, Object value) {
		return data.setHashJavaObject(sessionId, key, value);
	}

	@Override
	public Future<Void> remove(String key) {
		return data.remove(sessionId, key);
	}

	@Override
	public Future<Set<String>> keys() {
		return data.keys(sessionId);
	}

	@Override
	public Future<Void> renew() {
		return data.remove(sessionId);
	}

	@Override
	public Future<Void> destory() {
		return null;
	}

	@Override
	public String id() {
		return sessionId;
	}

	@Override
	public Future<Void> setExpire(int seconds) {
		return data.setExpire(sessionId, seconds);
	}
	
}
